#include "header.h"

/*Usage: ./01_open*/
int main(int argc, char* argv[]){
	ARGS_CHECK(argc, 2);
	int fd = open(argv[1], O_RDWR);
	ERROR_CHECK(fd, -1, "open");

	char buf[4] = {0};

	int cnt;
	while((cnt = read(fd, buf, sizeof(buf) - 1)) > 0){
		//printf("cnt = %d\n", cnt);
		printf("buf = %.*s\n", cnt, buf);

	}
	//用完就关
	close(fd);
	
	return 0;
}